package com.company;

public class bank {
        private int sum = 0;
        public synchronized void addMoney(int money) {
            sum += money;
            System.out.println(System.currentTimeMillis() + "存进" + money);
        }
        public void subMoney(int money) {
            if (sum - money < 0) {
                System.out.println("余额不足");
                return;
            } else {
                sum -= money;
                System.out.println(System.currentTimeMillis() + "取出" + money);
            }

        }
        public void lookMoney() {
            System.out.println("账户余额" + sum);
        }

    }

